home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 19 / develop 19 code / SimpliFace_V2 / Sources / ObjModelEvents.cp < prev    next >
Encoding:
Text File  |  1994-05-01  |  15.7 KB  |  605 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ObjModelEvents.cp
  3.  
  4.     Contains:    Apple Event handlers implementation
  5.  
  6.  
  7.     Developed by:
  8.  
  9.     Paul G Smith (commstalk hq & Full Moon Software, Inc)
  10.  
  11.     you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  12.     BUT I prefer to be contacted by e-mail
  13.     AppleLink:     COMMSTALK.HQ
  14.     Internet:     COMMSTALK.HQ@applelink.apple.com
  15.  
  16.     "SimpliFace2" Sample code to accompany develop article
  17.     on techniques for controlling script inheritance.
  18.     
  19.     
  20.  
  21.  
  22.     Apple Event handlers for SimpliFace2
  23.  
  24. */
  25.  
  26. #ifndef __STDIO__
  27. #include <StdIO.h>
  28. #endif
  29.  
  30. #ifndef __MENUS__
  31. #include <Menus.h>
  32. #endif
  33. #ifndef __EVENTS__
  34. #include <Events.h>
  35. #endif
  36. #ifndef __WINDOWS__
  37. #include <Windows.h>
  38. #endif
  39. #ifndef __DIALOGS__
  40. #include <Dialogs.h>
  41. #endif
  42. #ifndef __QUICKDRAW__
  43. #include <Quickdraw.h>
  44. #endif
  45. #ifndef __RESOURCES__
  46. #include <Resources.h>
  47. #endif
  48. #ifndef __MEMORY__
  49. #include <Memory.h>
  50. #endif
  51. #ifndef __FILES__
  52. #include <Files.h>
  53. #endif
  54. #ifndef __STANDARDFILE__
  55. #include <StandardFile.h>
  56. #endif
  57. #ifndef __SYSEQU__
  58. #include <SysEqu.h>
  59. #endif
  60. #ifndef __PLSTRINGFUNCS__
  61. #include <PLStringFuncs.h>
  62. #endif
  63.  
  64. #ifndef __AERegistry__
  65. #include <AERegistry.h>
  66. #endif
  67. #ifndef __ASREGISTRY__
  68. #include <ASRegistry.h>
  69. #endif
  70. #ifndef __APPLEEVENTS__
  71. #include <AppleEvents.h>
  72. #endif
  73. #ifndef __AEOBJECTS__
  74. #include <AEObjects.h>
  75. #endif
  76. #ifndef __OSA__
  77. #include <OSA.h>
  78. #endif
  79. #ifndef __APPLESCRIPT__
  80. #include <AppleScript.h>
  81. #endif
  82. #ifndef __ASDEBUGGING__
  83. #include <ASDebugging.h>
  84. #endif
  85.  
  86. #ifndef __AEOMTOKENS__
  87. #include "ObjModelTokens.h"
  88. #endif
  89. #ifndef __AEOMEVENTS__
  90. #include "ObjModelEvents.h"
  91. #endif
  92.  
  93. #ifndef __SCRIPTOBJECTS__
  94. #include "ScriptableObjects.h"
  95. #endif
  96.  
  97. #ifndef __SCRIPTUTILS__
  98. #include "ScriptUtils.h"
  99. #endif
  100.  
  101.  
  102. extern "C" {
  103. #include "AEBuild.h"
  104. #include "AEBuildGlobals.h"
  105. #include "AEPrint.h"
  106. }
  107. #include "AEBuildErrMsgs.h"
  108.  
  109.  
  110. #include "DebugTrace.h"
  111.  
  112.  
  113. #pragma segment AEventHandlers
  114.  
  115.  
  116. void    DumpAppleEvent(char *msg, AEDesc *desc)
  117. {
  118.     if (msg)
  119.         printf("%s", msg);
  120.         
  121.     if (desc)
  122.     {
  123.         char    buf[3000];
  124.         if (AEPrint(desc, buf, 3000) == 0)
  125.         {
  126.             printf(buf);
  127.             printf("\n");
  128.         }
  129.     }
  130. }
  131.  
  132. OSErr GetCurrentAppFileSpec(short *vRefNum, long *dirID, StringPtr fileName)
  133. {
  134.     OSErr                err = 0;
  135.     ProcessInfoRec        pInfo;
  136.     ProcessSerialNumber    pNum;
  137.     FSSpec                fSpec;
  138.     
  139.     err = GetCurrentProcess(&pNum);
  140.     if (err == noErr) 
  141.     {
  142.         pInfo.processInfoLength = sizeof(pInfo);
  143.         pInfo.processName = NULL;
  144.         pInfo.processAppSpec = &fSpec;
  145.         err = GetProcessInformation(&pNum, &pInfo);
  146.     }
  147.     if (err == noErr) 
  148.     {
  149.         *vRefNum = fSpec.vRefNum;
  150.         *dirID = fSpec.parID;
  151.         PLstrcpy((StringPtr)fileName, fSpec.name);
  152.     }    
  153.     
  154.     return err;
  155. }
  156.  
  157.  
  158. void GetCurrAppName(CStr255& appName)
  159. {
  160.     short             vRefNum;
  161.     long             dirID;
  162.     Str255            fileName;
  163.     OSErr             err = GetCurrentAppFileSpec(&vRefNum, &dirID, (StringPtr)fileName);
  164.     
  165.     if (err == noErr)
  166.         appName = fileName;
  167. }
  168.  
  169.  
  170.  
  171.  
  172. #define optionKeyCode     0x3A
  173. #define shiftKeyCode     0x38
  174. #define cmdKeyCode         0x37
  175. #define ctrlKeyCode     0x3B
  176.  
  177. static Boolean isKeyDown(long keyCode)
  178. {
  179.     KeyMap keys;
  180.     Byte *keysBytes;
  181.     
  182.     GetKeys(keys);
  183.     
  184.     keysBytes = (Byte *)keys;
  185.  
  186.     return((keysBytes[keyCode/8] & (1 << keyCode % 8)) != 0);
  187. }
  188.  
  189.  
  190.  
  191. static pascal  Boolean StdIdleFunction (EventRecord *theEventRecord,
  192.                                         long *sleepTime,
  193.                                         RgnHandle *mouseRgn)
  194. {
  195.     return    false;
  196. }
  197.  
  198.  
  199. static pascal OSErr GetAETEAEvtHandler  (AppleEvent *theEvent, 
  200.                                         AppleEvent *theReply, 
  201.                                         long theRefCon)
  202. {
  203.     OSAError         err = errAEEventNotHandled;
  204.     AEDesc            dataDesc, resultDesc;
  205.     short            languageCode;
  206.     
  207.     InitAEDescs(&dataDesc, &resultDesc, kEndOfList);
  208.     
  209.     err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &dataDesc);
  210.     if (err == noErr)
  211.         err = GetIntegerFromDescriptor(&dataDesc, &languageCode);
  212.     if (err == noErr)
  213.         err = AECreateList(NULL, 0, false, &resultDesc);
  214.         
  215.     if (err == noErr && gSimpliFace2)
  216.         err = gSimpliFace2->CollectAETEs(languageCode, resultDesc);
  217.         
  218.     if (err == noErr)
  219.         err = AEPutParamDesc(theReply, keyDirectObject, &resultDesc);
  220.  
  221.     DisposeAEDescs(&dataDesc, &resultDesc, kEndOfList);
  222.     
  223.     return (OSErr)err;
  224. }
  225.  
  226.  
  227. long eventHandlerDepth = 0;
  228.  
  229. static pascal OSErr ExecuteEventInContext (AppleEvent *theEvent, 
  230.                                         AppleEvent *theReply, 
  231.                                         TScriptableObject* theScriptableObj)
  232. {
  233.     OSAError            err = errAEEventNotHandled;
  234.     OSAID                 theScriptID = kOSANullScript;
  235.     
  236.     eventHandlerDepth++;
  237. //    printf("[%ld] entering ExecuteEventInContext: ", eventHandlerDepth);
  238. //    DumpAppleEvent("", theEvent);
  239.  
  240.     if (theScriptableObj)
  241.         theScriptID = theScriptableObj->GetObjScript();
  242.     else if (gScriptAdministrator)
  243.         theScriptID = gScriptAdministrator->GetSharedScript();
  244.         
  245.     // pass to script for handling
  246.     if (theScriptID != kOSANullScript)
  247.     {
  248.         AEHandlerProcPtr            oldResumeProc;
  249.         long                        oldRefcon;
  250.  
  251.         OSAGetResumeDispatchProc(gScriptingComponent, &oldResumeProc, &oldRefcon);
  252. #ifdef qUseOSAinheritance
  253.         TScriptableObject* parentObj = NULL;
  254.         if (theScriptableObj)
  255.         {
  256.             parentObj = theScriptableObj->GetParentObj();
  257.             if (theScriptableObj == parentObj)
  258.             {
  259.                 printf("[%ld] •••big problem: recursive context chain\n", 
  260.                             eventHandlerDepth);
  261.                 return errAEEventFailed;    // (should never happen, but...) barf
  262.             }
  263.             err = OSASetResumeDispatchProc(gScriptingComponent, 
  264.                                             (AEHandlerProcPtr)&ExecuteEventInContext, 
  265.                                             (long)parentObj);
  266.         }
  267.         else
  268.             err = OSASetResumeDispatchProc(gScriptingComponent, 
  269.                                             kOSAUseStandardDispatch, kOSADontUsePhac);
  270. #else
  271.         err = OSASetResumeDispatchProc(gScriptingComponent, 
  272.                                         kOSAUseStandardDispatch, kOSADontUsePhac);
  273. #endif
  274.         if (err == noErr)
  275.         {
  276.             printf("[%ld] handing script id (%ld) to OSADoEvent\n", 
  277.                     eventHandlerDepth, theScriptID);
  278.             err = OSADoEvent(gScriptingComponent, theEvent, theScriptID, 
  279.                              kOSAModeAlwaysInteract, theReply);
  280. #ifdef qUseOSAinheritance
  281.             if (err == errAEEventNotHandled)
  282.             {
  283.                 if (theScriptableObj)
  284.                 {
  285.                     printf("[%ld] not handled, so making recursive call to ExecuteEventInContext\n", 
  286.                             eventHandlerDepth);
  287.                     err = ExecuteEventInContext(theEvent, theReply, parentObj);
  288.                 }
  289.                 else    // otherwise, dispatch direct to standard handler
  290.                     err = StdAEvtHandler(theEvent, theReply, 0);
  291.             }
  292. #endif
  293.         }
  294.         OSASetResumeDispatchProc(gScriptingComponent, oldResumeProc, oldRefcon);
  295.     }
  296.     else
  297.         printf("ExecuteEventInContext was handed a null script for execution\n");
  298.  
  299.     if (err)
  300.         printf("[%ld] ExecuteEventInContext: err = %d\n", eventHandlerDepth, err);
  301.     
  302.     eventHandlerDepth--;
  303.     return    (OSErr)err;
  304. }
  305.  
  306.  
  307. static pascal OSErr StdAEvtPreHandler  (AppleEvent *theEvent, 
  308.                                         AppleEvent *theReply, 
  309.                                         long theRefCon)
  310. {
  311.     OSAError             err = errAEEventNotHandled;
  312.     AEEventClass         theEvtClass;
  313.     AEEventID             theEvtID;
  314.     DescType            theType;
  315.     Size                theSize;
  316.     AEDesc                directParam, theTokenDesc;
  317.     TScriptableObject*    theScriptableObj = NULL;
  318.     TScriptableObject*    savedParent = NULL;
  319.     objModelTokenPtr     theToken = nil;
  320.     Boolean                madeAppToken = false;
  321.     DescType             theTokenClass;
  322.     DescType            dirParamType;
  323.     
  324.     theTokenDesc.descriptorType = typeNull;
  325.     theTokenDesc.dataHandle = nil;
  326.  
  327.     // Extract the class and ID of the event from the AppleEvent
  328.     AEGetAttributePtr(theEvent, keyEventClassAttr, typeType, &theType, (Ptr) &theEvtClass, sizeof(theEvtClass), &theSize); 
  329.     AEGetAttributePtr(theEvent, keyEventIDAttr, typeType, &theType, (Ptr) &theEvtID, sizeof(theEvtID), &theSize); 
  330.     
  331.     DumpAppleEvent("••StdAEvtPreHandler: ", theEvent);
  332.     
  333.     if (isKeyDown(ctrlKeyCode) && isKeyDown(cmdKeyCode))
  334.         ;    // let user override scripted events by keying control-command
  335.     else if ((theEvtClass == kCoreEventClass && theEvtID != kAEOpenApplication)
  336.             || (theEvtClass == kAECoreSuite && theEvtID != kAESetData && theEvtID != kAEGetData)
  337.             || (theEvtClass == kSignature && theEvtID == kAESystemEvent)
  338.             || (theEvtClass == kASAppleScriptSuite && theEvtID == kASSubroutineEvent))
  339.     {    // above test is to make sure we handle all the scriptable events 
  340.         // and that we skip the ones we don't want to be scriptable
  341.         err = AEGetParamDesc(theEvent, keyDirectObject, typeWildCard, &directParam);
  342.         if (err == noErr)
  343.         {
  344.             dirParamType = directParam.descriptorType;
  345.             if (dirParamType == typeObjectSpecifier)
  346.             {
  347.                 printf("resolving direct parameter\n");
  348.                 err = AEResolve(&directParam, kAEIDoMinimum, &theTokenDesc);
  349.                 AEDisposeDesc(&directParam);
  350.                 if (err == noErr)
  351.                     theToken = ObjModelTokenFromDesc(&theTokenDesc);
  352.             }
  353.         }
  354.         if (!theToken && dirParamType != typeObjectSpecifier)
  355.         {
  356.             printf("no direct parameter resolved; resolving subject attribute\n");
  357.             err = AEGetAttributeDesc(theEvent, keySubjectAttr, 
  358.                                      typeWildCard, &directParam);
  359.             if (err == noErr)
  360.             {
  361.                 dirParamType = directParam.descriptorType;
  362.                 err = AEResolve(&directParam, kAEIDoMinimum, &theTokenDesc);
  363.                 AEDisposeDesc(&directParam);
  364.                 if (err == noErr)
  365.                     theToken = ObjModelTokenFromDesc(&theTokenDesc);
  366.             }
  367.         }
  368.         if (err == errAENoSuchObject)    // ••• HIDE OBJECT NOT FOUND ERRORS •••
  369.         {                                // ... in event pre-handler only...
  370.             err = errAEEventNotHandled;    // (let the real event handler find obj)
  371.         }
  372.  
  373.         if (!theToken)
  374.         {
  375.             if (dirParamType != typeObjectSpecifier)
  376.             {
  377.                 printf("no subject attribute resolved; making app token\n");
  378.                 err = MakeAppToken((TObjModelToken**)&theToken);
  379.                 madeAppToken = (err == noErr);
  380.             }
  381.             else
  382.                 printf("failed to resolve object specifier: object doesn't exist\n");
  383.         }
  384.     
  385.         if (err == noErr && theToken)
  386.             err = gScriptAdministrator->GetAttachedScript(theToken->GetTokenObj(), 
  387.                                                             theScriptableObj,
  388.                                                             savedParent);
  389.         if (err == noErr)
  390.         {    // pass to script for handling
  391.             if (theScriptableObj)
  392.                 err = ExecuteEventInContext(theEvent, theReply, theScriptableObj);
  393.             else
  394.             {
  395.                 printf("->GetAttachedScript did not return a scriptable object\n");
  396.                 err = errAEEventNotHandled;
  397.             }
  398.             if (theToken)
  399.                 gScriptAdministrator->ReleaseAttachedScript(theToken->GetTokenObj(),
  400.                                                             savedParent);
  401.         }
  402.         // this will dispose of the token as well as the descriptor, so
  403.         AEDisposeToken(&theTokenDesc); // DO NOT CALL until done with 'theToken'
  404.         if (madeAppToken)
  405.             delete theToken; // this will only be executed if token was made in this function
  406.     }
  407.     
  408.     if (err == errAEEventNotHandled)
  409.         printf("StdAEvtPreHandler: Apple Event not handled in pre-handler\n");
  410.     else if (err)
  411.         printf("StdAEvtPreHandler: err = %d\n", err);
  412.     
  413.     return (OSErr)err;
  414. }
  415.  
  416.  
  417. static pascal OSErr RqdAEvtHandler (AppleEvent *theEvent, 
  418.                                         AppleEvent *theReply, 
  419.                                         long theRefCon)
  420. {
  421.     OSErr            err = errAEEventNotHandled;
  422.     AEEventClass     theEvtClass;
  423.     AEEventID         theEvtID;
  424.     DescType        theType;
  425.     Size            theSize;
  426.  
  427.     // Extract the class and ID of the event from the AppleEvent
  428.     AEGetAttributePtr(theEvent, keyEventClassAttr, typeType, &theType, (Ptr) &theEvtClass, sizeof(theEvtClass), &theSize); 
  429.     AEGetAttributePtr(theEvent, keyEventIDAttr, typeType, &theType, (Ptr) &theEvtID, sizeof(theEvtID), &theSize); 
  430.  
  431.     printf("•RqdAEvtHandler: class=%.4s, id=%.4s\n", &theEvtClass, &theEvtID);
  432.  
  433.     if (theEvtClass == kCoreEventClass)
  434.     {
  435.         if (theEvtID == kAEOpenApplication)
  436.         {
  437.             if (isKeyDown(ctrlKeyCode) && isKeyDown(cmdKeyCode))
  438.                 ;
  439.             else
  440.             {
  441.                 if (gScriptAdministrator)
  442.                     gScriptAdministrator->RunStartupScript();
  443.                 err = 0;
  444.             }
  445.         }
  446.         else if (theEvtID == kAEQuitApplication)
  447.         {
  448.             err = 0;
  449.             gSimpliFace2->Terminate();    // quit after next time around event loop
  450.         }
  451.     }
  452.     
  453.     printf("RqdAEvtHandler: err = %d\n", err);
  454.  
  455.     return    err;
  456. }
  457.  
  458.  
  459. static pascal OSErr DoScriptAEvtHandler (AppleEvent *theEvent, 
  460.                                         AppleEvent *theReply, 
  461.                                         long theRefCon)
  462. {
  463.     OSAError        err = errAEEventNotHandled;
  464.     AEEventClass     theEvtClass;
  465.     AEEventID         theEvtID;
  466.     DescType        theType;
  467.     Size            theSize;
  468.  
  469.     // Extract the class and ID of the event from the AppleEvent
  470.     AEGetAttributePtr(theEvent, keyEventClassAttr, typeType, &theType, (Ptr) &theEvtClass, sizeof(theEvtClass), &theSize); 
  471.     AEGetAttributePtr(theEvent, keyEventIDAttr, typeType, &theType, (Ptr) &theEvtID, sizeof(theEvtID), &theSize); 
  472.  
  473.     printf("•DoScriptAEvtHandler: class=%.4s, id=%.4s\n", &theEvtClass, &theEvtID);
  474.  
  475.     if (gScriptAdministrator)
  476.     {
  477.         AEDesc            sourceDesc, resultDesc;
  478.  
  479.         InitAEDescs(&sourceDesc, &resultDesc, kEndOfList);
  480.         
  481.         err = AEGetParamDesc(theEvent, keyDirectObject, typeChar, &sourceDesc);
  482.         if (err == noErr)
  483.             err = gScriptAdministrator->DoScript(&sourceDesc, &resultDesc);
  484.         if (err == noErr)
  485.             err = AEPutParamDesc(theReply, keyDirectObject, &resultDesc);
  486.  
  487.         DisposeAEDescs(&sourceDesc, &resultDesc, kEndOfList);
  488.     }
  489.     
  490.     printf("DoScriptAEvtHandler: err = %ld\n", err);
  491.  
  492.     return    err;
  493. }
  494.  
  495.  
  496. static pascal OSErr StdAEvtHandler       (AppleEvent *theEvent, 
  497.                                         AppleEvent *theReply, 
  498.                                         long theRefCon)
  499. {
  500.     OSAError             err = errAEEventNotHandled;
  501.     AEEventClass         theEvtClass;
  502.     AEEventID             theEvtID;
  503.     DescType            theType;
  504.     Size                theSize;
  505.     AEDesc                directParam, theTokenDesc;
  506.     TObjModelToken         *theToken = nil;
  507.     Boolean                madeAppToken = false;
  508.     
  509.     theTokenDesc.descriptorType = typeNull;
  510.     theTokenDesc.dataHandle = nil;
  511.  
  512.     // Extract the class and ID of the event from the AppleEvent
  513.     AEGetAttributePtr(theEvent, keyEventClassAttr, typeType, &theType, (Ptr) &theEvtClass, sizeof(theEvtClass), &theSize); 
  514.     AEGetAttributePtr(theEvent, keyEventIDAttr, typeType, &theType, (Ptr) &theEvtID, sizeof(theEvtID), &theSize); 
  515.  
  516.     printf("•StdAEvtHandler: class=%.4s, id=%.4s\n", &theEvtClass, &theEvtID);
  517.  
  518.     if (theEvtClass == kASAppleScriptSuite && theEvtID == kAECreateElement)
  519.         return GetAETEAEvtHandler(theEvent, theReply, theRefCon);
  520.     else if (theEvtClass == kAEMiscStandards && theEvtID == kAEDoScript)
  521.         return DoScriptAEvtHandler(theEvent, theReply, theRefCon);
  522.     else if (theEvtClass == kCoreEventClass && theEvtID != kAEOpen)
  523.         return RqdAEvtHandler(theEvent, theReply, theRefCon);
  524.     else if (theEvtClass == kAECoreSuite && theEvtID == kAECreateElement)
  525.     {
  526.         err = MakeAppToken(&theToken);
  527.         madeAppToken = (err == noErr);
  528.     }
  529.     else
  530.     {
  531.         err = AEGetParamDesc(theEvent, keyDirectObject, typeWildCard, &directParam);
  532.         if (err == noErr)
  533.         {
  534.             if (theEvtClass == kCoreEventClass 
  535.                  && theEvtID == kAEOpenDocuments
  536.                  && (directParam.descriptorType == typeAEList))
  537.             {
  538.                 // open documents here
  539.                 err = errAEEventNotHandled;
  540.             }
  541.             else 
  542.             {
  543.                 err = AEResolve(&directParam, kAEIDoMinimum, &theTokenDesc);
  544.         
  545.                 if (err == noErr)
  546.                     theToken = (TObjModelToken*)ObjModelTokenFromDesc(&theTokenDesc);
  547.             }
  548.             AEDisposeDesc(&directParam);
  549.         }
  550.         
  551.         if (err)
  552.         {
  553.             err = MakeAppToken(&theToken);
  554.             madeAppToken = (err == noErr);
  555.         }
  556.     }
  557.     if (theToken)
  558.     {
  559.         err = theToken->DispatchAppleEvent(theEvent, theReply, theEvtClass, theEvtID);
  560.     }
  561.     // this will dispose of the token as well as the descriptor, so
  562.     AEDisposeToken(&theTokenDesc); // DO NOT CALL until done with 'theToken'
  563.     if (madeAppToken)
  564.         delete theToken; // this will only be executed if token was made in this function
  565.     
  566.     printf("StdAEvtHandler: err = %ld\n", err);
  567.     
  568.     return (OSErr)err;
  569. }
  570.  
  571.  
  572.  
  573. // installation
  574.  
  575. pascal OSErr InstallEventHandlers(void)
  576. {
  577.     OSErr err = 0;
  578.     
  579.     err = AEInstallSpecialHandler(keyPreDispatch, (EventHandlerProcPtr)&StdAEvtPreHandler, false);
  580.  
  581.     if (err == noErr) 
  582.         err = AEInstallEventHandler(typeWildCard, typeWildCard,
  583.                                     (EventHandlerProcPtr)&StdAEvtHandler, 0, false);
  584. /*--------
  585.     if (err == noErr) err = AEInstallEventHandler(kASAppleScriptSuite, kGetAETE, (EventHandlerProcPtr)&GetAETEAEvtHandler, (long)kGetAEUT, false);
  586.  
  587.     if (err == noErr) err = AEInstallEventHandler(kCoreEventClass, typeWildCard, (EventHandlerProcPtr)&RqdAEvtHandler, 0, false);
  588.     
  589.     if (err == noErr) err = AEInstallEventHandler(kAECoreSuite, typeWildCard, (EventHandlerProcPtr)&StdAEvtHandler, 0, false);
  590.     if (err == noErr) err = AEInstallEventHandler(kCoreEventClass, kAEOpen, (EventHandlerProcPtr)&StdAEvtHandler, (long)kAEOpen, false);
  591.  
  592.     if (err == noErr) err = AEInstallEventHandler(kAEMiscStandards, kAEDoScript, (EventHandlerProcPtr)&DoScriptAEvtHandler, (long)kAEDoScript, false);
  593. ---------*/
  594.     return err;
  595. }
  596.  
  597. pascal OSErr DeInstallEventHandlers(void)
  598. {
  599.     OSErr err = 0;
  600.     
  601.     return err;
  602. }
  603.  
  604.  
  605.